<?php
class visual_tasks extends object {
public $uid="";
public $date="";

function visual_tasks($uid,$date) {
	$this->uid=$uid;
	$this->date=$date;	
	}

function visual_tasks_simple_view_old() {
	$out="";	
	$datetime=new core_time;
	$datetime->date=$this->date;
	$datetime->time='00:01';
	$timestart=$datetime->totimestamp();
	$datetime->time='23:59';
	$timestop=$datetime->totimestamp();
	$query="select * from userjobs where from_ > ".$timestart." AND from_ < ".$timestop." AND uid=".$this->uid."";
	$result=mysql_query("$query");
	if ($result != "") {
	while ($row=mysql_fetch_array($result)) {
		$out=$out."<br>".$row['jdesc']."   ".$datetime->totimedef($row['from_'])." - ".$datetime->totimedef($row['to_'])." | ".$datetime->tohm($row['duration'])." | ".$row['note'];
		}	
	}
	return $out;
	}

function visual_tasks_lasttime() {
	$out="";	
	$datetime=new core_time;
	$datetime->date=$this->date;
	$datetime->time='00:01';
	$timestart=$datetime->totimestamp();
	$datetime->time='23:59';
	$timestop=$datetime->totimestamp();
	$query="select max(to_) as totime from userjobs where from_ > ".$timestart." AND from_ < ".$timestop." AND uid=".$this->uid."";
	$result=mysql_query("$query");
	if ($result != "") {
		$row=mysql_fetch_array($result);
		$out=$row['totime'];
			
	}
	return $out;	
	}
	
	
function visual_tasks_simple_view() {
	if ($_SESSION['role']==3) {
		$edit1="noedit";
		$edit2="noedit";
		} else {
		$edit1="edittimeto";
		$edit2="edit";
		}
	$out="";	
	$datetime=new core_time;
	$datetime->date=$this->date;
	$datetime->time='00:01';
	$timestart=$datetime->totimestamp();
	$datetime->time='23:59';
	$timestop=$datetime->totimestamp();
	$query="select * from userjobs where from_ > ".$timestart." AND from_ < ".$timestop." AND uid=".$this->uid." ORDER BY from_";
	$result=mysql_query("$query");
	if ($result != "") {
	while ($row=mysql_fetch_array($result)) {
		$out=$out."<div class='noborder'><span id='jobname'>".$row['jdesc']."</span>  <span class='edittimefrom' id='".$row['id']."'>".$datetime->totimedef($row['from_'])."</span> - <span class='".$edit1."' id='".$row['id']."'>".$datetime->totimedef($row['to_'])."</span> | ".$datetime->tohm($row['duration'])." | <span class='".$edit2."' id='".$row['id']."' style='display: inline'>".$row['note']."</span> | <span class='delete' onClick='deletetask(".$row['id'].")'>delete</span></div>";
		}	
	}
	return $out;
	}	
	
function visual_tasks_simple_view_table() {
	$loc = new loc;
	if ($_SESSION['role']==3) {
		$edit1="noedit";
		$edit2="edit";
		} else {
		$edit1="edittimeto";
		$edit2="edit";
		}
	$out="";	
	$datetime=new core_time;
	$datetime->date=$this->date;
	$datetime->time='00:01';
	$timestart=$datetime->totimestamp();
	$datetime->time='23:59';
	$timestop=$datetime->totimestamp();
	$query="select * from userjobs where from_ > ".$timestart." AND from_ < ".$timestop." AND uid=".$this->uid." ORDER BY from_";
	$result=mysql_query("$query");
	if ($result != "") {
	while ($row=mysql_fetch_array($result)) {
		$out=$out."<tr class='onetask'><td id='fromtime'><span class='explain'>".$loc->from."</span><br> <span class='edittimefrom' id='".$row['id']."'>".$datetime->totimedef($row['from_'])."</span> </td><td id='totimetd'> <span class='explain'>".$loc->to."</span><br><span class='".$edit1."' id='".$row['id']."'>".$datetime->totimedef($row['to_'])."</span> </td><td id='durationtime'><span class='explain'>".$loc->duration."</span><br> ".$datetime->tohm($row['duration'])."</td><td id='namejob'><span class='explain'>".$loc->namejob."</span><br><span id='jobname'>".$row['jdesc']."</span></td> <td id='noteedit'> <span class='explain'>".$loc->note."</span><br><span class='".$edit2."' id='".$row['id']."' style='display: inline'>".$row['note']."</span> </td><td> <span class='delete' onClick='deletetask(".$row['id'].")'>delete</span></td></tr> ";
		}	
	}
	return $out;
	}	
}
?>
